<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<div class="button_area">
	<a href="order/order.info.action"  class="button">添加订单</a>&nbsp;&nbsp;
	&nbsp;&nbsp;	
	<a class="button submit">保存</a>&nbsp;&nbsp;
	<a href="order/companys.action" class="button">返回</a>
</div>
<s:form method="post" action="saveCompany" 
	namespace="/order">

	<tr>
		<td>
			<table class="form_table">
				<s:hidden name="company.custCompanyId"></s:hidden>
				<s:textfield label="公司名称" name="company.custCompanyName" size="50"  readonly="true"
					required="true" maxlength="100"></s:textfield>
				<s:textfield label="公司地址" name="company.address" size="50"  readonly="true"
					required="true" maxlength="100"></s:textfield>
				<s:textfield label="联系电话" name="company.phoneNumber" size="50"  readonly="true"
					required="true" maxlength="100"></s:textfield>
			</table>
		</td>
		<td width="30">
			&nbsp; 
		</td>
		<td>
			<table class="form_table">
				<s:textfield label="联系传真" name="company.faxNumber" size="30" readonly="true"
					 maxlength="100"></s:textfield>
				<s:textfield label="邮政编码" name="company.postalCode" size="30"  readonly="true"
					 maxlength="100"></s:textfield>
			</table>
		</td>
	</tr>
	<tr><td></td></tr>

</s:form>

<br>

<table id="order_list" width="100%" border="0" cellspacing="0"cellpadding="0"></table>
<div id="order_pager"></div>
<br>
<table id="log_list" width="100%" border="0" cellspacing="0"cellpadding="0"></table>
<div id="log_pager"></div>
<style>
<!--
.form_table {
	text-align: left;
	background-color:#F4F4F4;
}
-->
</style>
<script type="text/javascript">
$(document).ready(function(){
$.jgrid.extend({
			deleteOrder:function(id){
			return this.each(function () {
    			var data=$(this).jqGrid('getRowData',id);
    			$(this).delGridRow(id,{url:'order/order.delete.action',caption:'请确认',msg:'确认删除此订单吗?',bSubmit:'确认',bCancel:'取消',reloadAfterSubmit:true});
    			})
    		},
			deleteLog:function(id){
			return this.each(function () {
    			var data=$(this).jqGrid('getRowData',id);
    			$(this).delGridRow(id,{url:'order/log.delete.action',caption:'请确认',msg:'确认删除 "'+data.appreYear+'"记录 吗?',bSubmit:'确认',bCancel:'取消',reloadAfterSubmit:true});
    			});
    		}
});
	$("#order_list").jqGrid({
			caption:"上单记录",    
			url:"order/order.list.action?id="+<s:property value="company.custCompanyId"/>,
    		colModel:[       
       			{label:'签单人姓名',name:'customer.customerName',index:'customer.customerName',sortable:false},     
        		{label:'签单人所在部门',name:'customer.section',index:'customer.section',sortable:false},
        		{label:'签单人职位',name:'customer.position',index:'customer.position',sortable:false},
        		{label:'签单人电话',name:'phoneNumber',index:'customer.phoneNumber',sortable:false},  
        		{label:'签单人邮箱',name:'customer.email',index:'customer.email',sortable:false},
        		{label:'上单时间',name:'dealDate',index:'dealDate',sortable:false,formatter:'date',formatoptions:{newformat:'Y-m-d'}},
        		{label:'项目类型',name:'projectType.dictionaryName',index:'projectType.dictionaryName',sortable:false},
        		{label:'项目信息',name:'projectDetail',index:'projectDetail',sortable:false},
        		{label:'联系业务人员姓名',name:'employee.employeeName',index:'employee.employeeName',sortable:false},
        		{label:' ',name:'del', width:100,align:'center',sortable:false}
      		],     
     		imgpath: '../theme/images/jqgrid/',      
    		pager: "#order_pager",   
      		multiselect: false,     
     		sortname: 'dealDate',
      		sortorder: "desc", 
      		datatype: 'json',     
      		jsonReader: {     
	      		root: "dataRows",
	      		repeatitems : false
     		},
     		gridComplete: function(){
				var ids = $(this).jqGrid('getDataIDs');
				for(var i=0;i < ids.length;i++){
					var cl = ids[i];
					var data=jQuery("#list").jqGrid('getRowData',cl);
					sc= "<a href='javascript:void(0)' onclick=\"$('#order_list').jqGrid('deleteOrder',"+cl+");\">删除</a>";
					$(this).jqGrid('setRowData',ids[i],{del:sc});
				}
			},
    		width:$(document).width()-80
			});
							
	jQuery("#log_list").jqGrid({      
			url:"order/log.list.action",
    		colModel:[     
       			{label:'年份',name:'appreYear',index:'appreYear',sortable:false},     
        		{label:'内容',name:'appreComments',index:'appreComments',sortable:false},
        		{label:' ',name:'del', width:100,align:'center',sortable:false}
      		],     
     		imgpath: '../theme/images/jqgrid/',      
    		pager: "#log_pager",   
      		multiselect: false,     
     		sortname: 'appreYear',
      		sortorder: "desc", 
      		datatype: 'json', 
      		caption:"历年答谢客户活动内容",   
      		jsonReader: {     
	      		root: "dataRows",
	      		repeatitems : false
     		},
     		gridComplete: function(){
				var ids = $(this).jqGrid('getDataIDs');
				for(var i=0;i < ids.length;i++){
					var cl = ids[i];
					var data=$(this).jqGrid('getRowData',cl);
					sc= "<a href='javascript:void(0)' onclick=\"$('#log_list').jqGrid('deleteLog',"+cl+");\">删除</a>";
					$(this).jqGrid('setRowData',ids[i],{del:sc});
				}
			},
    		width:$(document).width()-80
			});	

		}); 
</script>

